package fun.shuofeng.juc.reentranlock;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockDemo01 {
    public static final ReentrantLock LOCK = new ReentrantLock();

    public static void main(String[] args) {
        LOCK.lock();
        try {
            System.out.println("main enter...");
            method1();
        } finally {
            LOCK.unlock();
        }
    }

    private static void method1() {
        LOCK.lock();
        try {
            System.out.println("method1 enter...");
            method2();
        } finally {
            LOCK.unlock();
        }
    }

    private static void method2() {
        LOCK.lock();
        try {
            System.out.println("method2 enter...");
        } finally {
            LOCK.unlock();
        }
    }
}
